# docker build -t swr.cn-central-221.ovaijisuan.com/wair/jupyterlab:pytorch2.1.2-cuda12.1-cudnn8-py39-centos7 .
FROM nvidia/cuda:12.1.0-cudnn8-devel-centos7

ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/openssl/lib

COPY pip.conf /root/.pip/pip.conf

RUN yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make libffi-devel wget git xz-devel python-backports-lzma -y
# 升级openssl到1.1.1
RUN cd /opt && wget --no-check-certificate https://www.openssl.org/source/openssl-1.1.1d.tar.gz && tar -zxvf  openssl-1.1.1d.tar.gz && cd openssl-1.1.1d && ./config --openssldir=/usr/local/openssl --prefix=/usr/local/openssl && make && make install
RUN echo "/usr/local/openssl/lib" >> /etc/ld.so.conf && ldconfig

# 安装python3.9
RUN cd /opt &&  wget https://publish-data.obs.cn-central-221.ovaijisuan.com:443/chenyang/Python-3.9.10.tgz && tar xzf Python-3.9.10.tgz && cd Python-3.9.10 && ./configure --with-openssl=/usr/local/openssl --enable-optimizations && make altinstall
RUN ln -s  /usr/local/bin/pip3.9 /usr/bin/pip3 && ln -s /usr/local/bin/python3.9 /usr/bin/python3
RUN pip3 install  jupyterlab

# 安装SSH
RUN yum install openssh-server -y
COPY sshd_config /etc/ssh/sshd_config
# 仅centos需要替换系统systemctl
COPY systemctl.py /usr/bin/systemctl
RUN chmod +x /usr/bin/systemctl
RUN ssh-keygen -t rsa -b 2048 -f /etc/ssh/ssh_root_rsa_key && ssh-keygen -t ecdsa -b 256 -f /etc/ssh/ssh_host_ecdsa_key && ssh-keygen -t ed25519 -b 256 -f /etc/ssh/ssh_host_ed25519_key

# 安装git-lfs、huggingface_hub
# RUN curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.rpm.sh | bash && yum install -y git-lfs  && git lfs install
RUN pip3 install -U huggingface_hub

# 安装vllm
RUN pip3 install torch torchvision torchaudio
RUN pip3 install vllm


RUN yum clean all && pip3 cache purge
#RUN systemctl restart sshd && systemctl enable sshd